package org.example;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void hello(){
        System.out.println("Hello world");
    }
    public static int maxSubArraySum(int[] arr) {
        int maxSum = arr[0];
        int currentSum = arr[0];

        for (int i = 1; i < arr.length; i++) {
            currentSum = Math.max(arr[i], currentSum + arr[i]);
            maxSum = Math.max(maxSum, currentSum);
        }

        return maxSum;
    }
    public static void prin(){
        int n = 20000;
        boolean[] isComposite = new boolean[n + 1];
        List<Integer> primes = new ArrayList<>();

        for (int i = 2; i <= n; i++) {
            if (!isComposite[i]) {
                primes.add(i);
                for (int j = i * i; j <= n; j += i) {
                    isComposite[j] = true;
                }
            }
        }

        int count = 0;
        for (int prime : primes) {
            System.out.print(prime + " ");
            count++;
            if (count % 5 == 0) {
                System.out.println();
            }
        }
    }
    public static void main(String[] args) {

        int[] arr1 = {1, -2, 3, 5, -1};
        hello();
        System.out.println("数组 [1, -2, 3, 5, -1] 的最大子数组和为：" + maxSubArraySum(arr1));
        System.out.println();
        prin();
    }
}
    